import Login from "@/pages/login/Login.vue";
import {createRouter, createWebHashHistory} from "vue-router";
import Main from "@/pages/Main.vue";
import Home from "@/pages/main/Home.vue";
import Appointment from "@/pages/main/Appointment.vue";
import Mine from "@/pages/main/Mine.vue";
import filmDetail from "@/pages/detail/FilmDetail.vue";
import appointmentDetail from "@/pages/detail/AppointmentDetail.vue";
import vipDetail from "@/pages/detail/VipDetail.vue";
import protocol from "@/pages/Protocol.vue";
import Register from "@/pages/login/Register.vue";
import VipOpen from "@/pages/login/VipOpen.vue";
import Forget from "@/pages/login/Forget.vue";

/** 路由配置 */
const routes = [
    {
        path: '/',
        component: Main,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'home',
                component: Home
            },
            {
                path: 'appointment',
                name: 'appointment',
                component: Appointment
            },
            {
                path: 'mine',
                name: 'mine',
                component: Mine
            }]
    },
    {
        path: '/login',
        name: 'login',
        component: Login
    },
    {
        path: '/register',
        name: 'register',
        component: Register
    },
    {
        path: '/forget',
        name: 'forget',
        component: Forget
    },
    {
        path: '/vip-open',
        name: 'vipOpen',
        component: VipOpen
    },
    {
        path: '/film-detail',
        name: 'filmDetail',
        component: filmDetail
    },
    {
        path: '/appointment-detail/:id',
        name: 'appointmentDetail',
        component: appointmentDetail
    },
    {
        path: '/vip-detail/:id',
        name: 'vipDetail',
        component: vipDetail
    },
    {
        path: '/protocol',
        name: 'protocol',
        component: protocol
    }
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach(async (to, from, next) => {
    console.log('beforeEach')
    // 界面跳转拦截
    next()
})

export default router

